import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		isLogin: uni.getStorageSync("loginUserInfo") ? true : false,
		// 存放当前登录用户的用户信息
		loginUserInfo:uni.getStorageSync("loginUserInfo") || {},
	},
	mutations: {
		//登录
		login(state, payload) {
			if (payload) {
				state.loginUserInfo = payload
				// console.log(state.loginUserInfo)
				uni.setStorageSync("loginUserInfo",state.loginUserInfo)
			}
			state.isLogin = true;
		},
		// 注销
		logout(state) {
			state.loginUserInfo = {}
			state.sessionId = null
			uni.removeStorageSync('loginUserInfo');
			uni.removeStorageSync('sessionId');
			state.isLogin = false;
		},
	},
	actions:{
		
	}
})

export default store
